﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<section class="content-header">
    <h1>
        IP黑名单管理
        <small></small>
    </h1>
    <ol class="breadcrumb"></ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header">
                    <div class="form-inline">
                        <div class="form-group">
                            <label>IP地址</label>
                            <input type="text" class="form-control" style="width:100px;" maxlength="20" id="txtIp" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <button type="button" class="btn btn-success btn-sm" id="btnSearch">查询</button>
                        </div>


                        <h3 class="box-title"></h3>
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body table-responsive no-padding">
                    <table class="table table-hover body-table-head">
                        <thead>
                            <tr>
                                <th>
                                    IP
                                </th>
                                <th>
                                    创建时间
                                </th>

                            </tr>
                        </thead>
                        <tbody id="tbodylist"></tbody>
                    </table>
                    <div class="no-data" id="nodata" style="display:none;">
                        <div class="img-box"></div>
                        <div class="text">暂无数据</div>
                    </div>
                </div>
                <div class="box-footer clearfix ">
                    <ul id="pagination" class="pagination pagination-sm no-margin pull-right"></ul>
                </div>
                <!-- /.box-body -->
                <!-- /.box -->
            </div>
        </div>
    </div>
</section>
@section scriptsBottom{
    <script src="@Url.Content("~/lib/art-template/template-web.js")"></script>
    <script id="dataItemTpl" type="text/html">
        {{each data}}
        <tr>          
            <td>
                {{$value.IP}}
            </td>
            <td>
                {{$value.CreatedTime}}
            </td>           
        </tr>
        {{/each}}
    </script>
    <script type="text/javascript">
        $(document).ready(function () {

            $("#btnSearch").click(function () {
                search();
            });

            search();
            $("#btnAdd").click(function () {
                edit('添加办事指南');
            });
        });

        //页码
        var pageIndex = 1;
        //查询
        function search() {
            var url = '@Url.Action("GetPage", "BlackListIP")'
            //查询列表
            $.ajax({
                url: url,
                type: 'GET',
                dataType: "json",
                data: {
                    ip:$("#txtIp").val(),
                    rows: 10,
                    page: pageIndex
                },
                success: function (data) {
                    if (data.data.length < 1) {
                        $("#nodata").show();
                        document.getElementById('tbodylist').innerHTML = "";
                        return;
                    }
                    $("#nodata").hide();
                    //模板渲染
                    var data = data;
                    var html = template('dataItemTpl', data);
                    document.getElementById('tbodylist').innerHTML = html;
                    //分页显示
                    $('#pagination').twbsPagination("destroy");
                    $('#pagination').twbsPagination({
                        totalItems: data.total,
                        visiblePages: 10,
                        pageSize: 10,
                        startPage: parseInt(pageIndex),
                        onPageClick: function (event, page) {
                            pageIndex = page;
                            search();
                        }
                    });
                }
            });
        }
    </script>
}




